﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DataAccessLayer;
using GlobalObjects;
using WCFServiceWebRole1.DataObjects;
using System.Web;
using System.ServiceModel.Web;
using System.Net;
using System.Diagnostics;

namespace DataAccessLayerTests
{
    [TestClass]
    public class SharedEntityTests
    {
        [TestMethod]
        public void shareDeviceWithUser_DAL_valid()
        {
            //arrange
            int device = 2113;
            int user = 1092;
            //act
            SharedEntity newSharing = new SharedEntity();
            newSharing.shareDeviceWithUser_DAL(device,user);
            //assert
        }

        [TestMethod]
        [ExpectedException(typeof(System.Data.Entity.Infrastructure.DbUpdateException))]
        public void shareDeviceWithUser_DAL_inValidUserId()
        {
            //arrange
            int device = 14;
            int user = 200120;
            //act
            SharedEntity newSharing = new SharedEntity();
            newSharing.shareDeviceWithUser_DAL(device, user);
            //assert
        }
        [TestMethod]
        [ExpectedException(typeof(System.Data.Entity.Infrastructure.DbUpdateException))]
        public void shareDeviceWithUser_DAL_inValidDeviceId()
        {
            //arrange
            int device = 140000;
            int user = 20;
            //act
            SharedEntity newSharing = new SharedEntity();
            newSharing.shareDeviceWithUser_DAL(device, user);
            //assert
        }
        [TestMethod]
        [ExpectedException(typeof(System.Data.Entity.Infrastructure.DbUpdateException))]
        public void shareDeviceWithUser_DAL_inValidOwner()
        {
            //arrange
            int device = 2113;
            int user = 1178;
            //act
            SharedEntity newSharing = new SharedEntity();
            newSharing.shareDeviceWithUser_DAL(device, user);
            //assert
        }
        [TestMethod]
        public void removeSharedDevice_DAL_valid() {
            //arrange
            int device = 2113;
            int user = 1092;
            SharedEntity Sharing = new SharedEntity();
            //act
            Sharing.removeSharedDevice(device,user);
            //Assert
        }
        [TestMethod]
        [ExpectedException(typeof(System.Data.Entity.Infrastructure.DbUpdateException))]
        public void removeSharedDevice_DAL_invalid()
        {
            //arrange
            int device = 211;
            int user = 1092;
            SharedEntity Sharing = new SharedEntity();
            //act
            Sharing.removeSharedDevice(device, user);
            //Assert
        }
    }
}
